<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <!-- react容器 -->
    <div id="test"></div>

    <!-- 引入react核心库 -->
    <script src="../lib/react.js"></script>
    <!-- 引入react-dom -->
    <script src="../lib/react-dom.js"></script>
    <!-- 引入babel -->
    <script src="../lib/babel.min.js"></script>
    <script type="text/babel">
      class Weather extends React.Component {
        constructor(props) {
          super(props);
          this.state = {
            isHot: true,
            wind: "微风",
          };
          this.changeWeather = this.changeWeather.bind(this);
        }
        render() {
          const { isHot, wind } = this.state;
          return (
            <h1 onClick={this.changeWeather}>
              今天天气很{isHot ? "热" : "冷"}，风为{wind}
            </h1>
          );
        }
        changeWeather() {
          const { isHot, wind } = this.state;
          this.setState({ isHot: !this.state.isHot, wind: "大风" });
        }
      }
      ReactDOM.render(<Weather />, document.getElementById("test"));
    </script>
  </body>
</html>
